<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        // 生成script标签, 并放到body的最后,需要先调用jsonp接口
        const script = document.createElement("script");
        script.src = "http://suggest.taobao.com/sug?code=utf-8&q=卫衣&callback=cb";
        document.body.appendChild(script);
        // 声明函数, 接收并处理数据
        const cb = (data) => {
            console.log(data);
            alert(data.result)
        };
        
    </script>
    <!-- 如果不需要动态调用接口,可以直接写在最下面,让定义的函数先加载,防止jsonp返回的回调函数执行时,找不到函数; -->
    <!-- <script src="http://suggest.taobao.com/sug?code=utf-8&q=卫衣&callback=cb"></script> -->
</body>
</html>